/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.bugeden.netdisk.vfs;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;


/**
 *
 * @author bug-eden
 */
public class FileX implements DiskInterface,Serializable,NetFile{

    static final long serialVersionUID = 423432L;
    /**
     * partition list
     */
   private  ArrayList<Partition> partitionList;
  
    /**
    * file name
    */
   private String name;

   /*
    * path
    */
   private String parentPath;

   /**
    * file size(byte)
    */
   private long size = 0;

   /**
    * file description
    */
   private String remark = "";

   /**
    * build time
    */
   private Date buildTime;

   public FileX( String name, String parentPath)
   {
       this.parentPath = new String( parentPath);
       this.name = new String(name);
       partitionList = new ArrayList<Partition>();
       buildTime  = new Date( );
   }

    public FileX( String name )
    {
        partitionList = new ArrayList<Partition>();
        this.name = new String( name );
        this.parentPath = new String( "");
        buildTime  = new Date( );
    }





    /**
     * @return the size
     */
    public long getSize() {
        return size;
    }

    /**
     * @param size the size to set
     */
    public void setSize(long size) {
        this.size = size;
    }

    /**
     * @return the remark
     */
    public String getRemark() {
        return remark;
    }

    /**
     * @param remark the remark to set
     */
    public void setRemark(String remark) {
        this.remark = remark;
    }

    /**
     * @return the buildTime
     */
    public Date getBuildTime() {
        return buildTime;
    }

    /**
     * @param buildTime the buildTime to set
     */
    public void setBuildTime(Date buildTime) {
        this.buildTime = buildTime;
    }

    /**
     *
     * @return partition number
     */
    public int getPartitionNub()
    {
        return partitionList.size();
    }

    /**
     *
     * @param part part to add
     */
    public void addPartition( Partition part )
    {
        partitionList.add(part);
    }

    /**
     *
     * @param index: partition position
     * @return partition on the specify position
     */
    public Partition getPartition( int index )
    {
        return (Partition) partitionList.get(index);
    }

    /**
     *
     * @param index
     * @return partition which have removed
     */
    public Partition  removePartition( int index )
    {
        return (Partition) partitionList.remove(index);
    }

    public void appendPath(String path) {
        this.setPath( path );
    }

    public void setFileName(String pname) {
        this.name = pname;
    }

    public String getFileName() {
        return this.name;
    }

    public String getName() {
        return this.name;
    }

    /**
     * @return the path
     */
    public String getPath() {
        String path = new String(this.parentPath);
        if( !parentPath.endsWith(DiskInterface.PathSeparator))
            path += PathSeparator;
        path += this.name;
        return path;
    }

    /**
     * @param path the path to set
     */
    public void setPath(String path) {
        this.parentPath = path;
    }

    public String getParentPath() {
        return this.parentPath;
    }
}
